ProgressStyle
Helper class for generating large-format notifications that display progress to the user with a highly customizable progress bar with segments, points, a custom tracker icon, and custom icons at the start and end of the progress bar. If the platform does not provide large-format notifications, this method has no effect. The user will always see the normal notification view. This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like so:
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_notification)
.setColor(Color.GREEN)
.setColorized(true)
.setContentTitle("Arrive 10:08 AM").
.setContentText("Dominique Ansel Bakery Soho")
.addAction(new NotificationCompat.Action("Exit navigation",...))
.setStyle(new NotificationCompat.ProgressStyle()
.setStyledByProgress(false)
.setProgress(456)
.setProgressTrackerIcon(IconCompat.createWithResource(R.drawable.ic_driving_tracker))
.addProgressSegment(new Segment(41).setColor(Color.BLACK))
.addProgressSegment(new Segment(552).setColor(Color.YELLOW))
.addProgressSegment(new Segment(253).setColor(Color.YELLOW))
.addProgressSegment(new Segment(94).setColor(Color.BLUE))
.addProgressPoint(new Point(60).setColor(Color.RED))
.addProgressPoint(new Point(560).setColor(Color.YELLOW))
)
Content copied to clipboard
NOTE: ProgressStyle Notifications are supported on Android 36 and above. If the SDK version is below 36, the ProgressStyle will fall back to the default notification style.
Types
Functions
Link copied to clipboard
This is called with the extras of the framework Notification during the build process, after
apply()
has been called.Link copied to clipboard
@NonNull
Adds another point.
Link copied to clipboard
@NonNull
Appends a segment to the end of the progress bar.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Gets the progress value of the progress bar.
Link copied to clipboard
Gets the progress bar end icon.
Link copied to clipboard
Gets the sum of the lengths of all Segments in the style, which defines the maximum progress.
Link copied to clipboard
Gets the points that are displayed on the progress bar.
Link copied to clipboard
Gets the segments that define the background layer of the progress bar.
Link copied to clipboard
Gets the progress bar start icon.
Link copied to clipboard
Gets the progress tracker icon for the progress bar.
Link copied to clipboard
Get indeterminate value of the progress bar.
Link copied to clipboard
Gets whether the progress bar's style is based on its progress.
Link copied to clipboard
@NonNull
Specifies the progress (in the same units as getLength) of the tracker along the length of the bar.
Link copied to clipboard
@NonNull
An optional square icon that appears at the end of the progress bar.
Link copied to clipboard
@NonNull
Used to indicate an initialization state without a known progress amount.
Link copied to clipboard
@NonNull
Replaces all the progress points.
Link copied to clipboard
@NonNull
Sets or replaces the segments of the progress bar.
Link copied to clipboard
@NonNull
An optional square icon that appears at the start of the progress bar.
Link copied to clipboard
@NonNull
An optional icon that can appear as an overlay on the bar at the point of current progress.
Link copied to clipboard
Indicates whether the segments and points will be styled differently based on whether they are behind or ahead of the current progress.